<template>
  <div class="question-zhzj-box">
      <div class="question-zhzj-lis-box">
          <div class="question-zhzj-label">题干：</div>
          <div class="question-zhzj-text">
              <div v-html="questionData.allTitle"></div>
          </div>
      </div>
      <div class="question-zhzj-lis-box" v-if="questionData.questionType != 5 && questionData.questionType != 6">
          <div class="question-zhzj-label">选项：</div>
          <div class="question-zhzj-text" v-if="questionData.questionType == 1 || questionData.questionType == 2">
              <div class="question-option-lis" v-for="(item,index) in questionData.optionList" :key="index">
                  {{Alphabet[index]}}、{{item.Content}}
              </div>
          </div>
          <div class="question-zhzj-text" v-if="questionData.questionType == 3">
              <div class="question-option-lis">A、正确</div>
              <div class="question-option-lis">B、错误</div>
          </div>
      </div>
      <div class="question-zhzj-lis-box">
          <div class="question-zhzj-label">参考答案：</div>
          <div class="question-zhzj-text" v-if="questionData.questionType == 6">
              <span v-html="setAnswer(questionData)"></span>
          </div>
          <div class="question-zhzj-text" v-else-if="questionData.questionType == 5">
              <div v-for="(answer,key) in questionData.questionAnswer" :key="key">填空{{key+1}}：{{answer}}</div>
          </div>
          <div class="question-zhzj-text" v-else>
              {{setAnswer(questionData)}}
          </div>
      </div>
      <div class="question-zhzj-lis-box">
          <div class="question-zhzj-label">答案解析：</div>
          <div class="question-zhzj-text">
              <div v-html="questionData.resultAnalysis"></div>
          </div>
      </div>
  </div>
</template>

<script>
export default {
    data() {
        return {
            Alphabet: [
                'A',
                'B',
                'C',
                'D',
                'E',
                'F',
                'G',
                'H',
                'I',
                'J',
                'K',
                'L',
                'M',
                'N',
                'O',
                'P',
                'Q',
                'R',
                'S',
                'T',
                'U',
                'V',
                'W',
                'X',
                'Y',
                'Z'
            ],
        }
    },
    props: {
        questionData: {
            type: Object,
            default: () => {}
        },
        answerList: {
            type: Array,
            default: () => []
        },
        answerContentList: {
            type: Array,
            default: () => []
        },
        subQuestionList: {
            type: Array,
            default: () => []
        }
  },
  methods:{
      setAnswer(data) {
          var answer = '';
          if (data.questionType == 1 || data.questionType == 2) {
              let answerList = [];
              let answers = data.answer.split(',');
              for (let i = 0; i < answers.length; i++) {
                  if (answers[i] != '') {
                      answerList.push(Number(answers[i]));
                  }
              }
              for (let key = 0; key < answerList.length; key++) {
                  if (key == 0) {
                      answer = this.Alphabet[answerList[key]];
                  } else {
                      answer = answer + ',' + this.Alphabet[answerList[key]];
                  }
              }
              return answer
          } else if(data.questionType == 3) {
              if (data.answer == 1) {
                return '错误'
              } else if (data.answer == 0){
                return '正确'
              }
          } else if (data.questionType == 6) {
              return data.answer
          }
      }
  }
}
</script>

<style>

</style>